package com.hlx.service.user.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hlx.entity.user.Customer;
import com.hlx.mapper.user.CustomerMapper;
import com.hlx.service.user.CustomerService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service

public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Override
    public List<Integer> getAllCustomerIdByCustomerUser(Integer customerUser) {
        LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(Customer::getCustomerUser,customerUser);
        return this.list(queryWrapper).stream().map(item->item.getId()).collect(Collectors.toList());
    }

    @Override
    public List<Integer> getAllCustomerByName(String customerName) {
        LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(Customer::getCustomerName,customerName);
        return this.list(queryWrapper).stream().map(item->item.getId()).collect(Collectors.toList());
    }
}
